package com.woniuxy.propertyjava.service.impl;

import com.woniuxy.propertyjava.dao.DeliverDao;
import com.woniuxy.propertyjava.entity.Deliver;
import com.woniuxy.propertyjava.entity.PageBean;
import com.woniuxy.propertyjava.service.DeliverService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : author
 * @create 2022/7/5 11:31
 */
@Service
public class DeliverServiceImpl implements DeliverService {

    @Resource(type = DeliverDao.class)
    DeliverDao deliverDao;

    @Override
    public PageBean<Deliver> getDeliverPageBean(Deliver deliver, int pageIndex, int pageSize) {
        PageBean<Deliver> pageBean = new PageBean<>();
        pageBean.setBeanList(deliverDao.selectDeliversByDeliverProperty(deliver, pageIndex, pageSize));
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setTotalRecode(deliverDao.count(deliver));
        return pageBean;
    }

    @Override
    public void insertDeliver(Deliver deliver) {
        deliverDao.insert(deliver);
    }

    @Override
    public void updataDeliver(Deliver deliver) {
        deliverDao.update(deliver);
    }

    @Override
    public void deleteDeliver(int deliverId) {
        deliverDao.deleteById(deliverId);
    }
}
